package com.cjh.mybatis04.mapping;


import com.cjh.mybatis04.session.Configuration;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @Descripton 映射语句类
 * @Author cjh
 * @Date 2023/5/26 11:09
 */
@NoArgsConstructor
@Getter
@Setter
public class MappedStatement {
    private Configuration configuration;
    /**
     * eg:com.cjh.mybatis03.IUserDao.queryUserInfoById
     */
    private String id;
    private SqlCommandType sqlCommandType;
    private BoundSql boundSql;

    /**
     *建造者
     */

    public static class Builder{
        private MappedStatement mappedStatement = new MappedStatement();
        public Builder(Configuration configuration,String id,SqlCommandType sqlCommandType,
                       BoundSql boundSql){
            mappedStatement.configuration = configuration;
            mappedStatement.id= id;
            mappedStatement.sqlCommandType = sqlCommandType;
            mappedStatement.boundSql = boundSql;
        }

        public MappedStatement build(){
            assert mappedStatement.configuration != null;
            assert mappedStatement.id != null;
            return mappedStatement;
        }
    }

}
